1.繼承性(Inheritance):可以讓物件繼承其他物件(class)的屬性與行為
2.C#之中,想要使用繼承只需要在定義 class 時,於 class 名稱後面加上「:」(冒號) 與被繼承的 class 名稱即可
Base Class(基底類別)
class Creature
    {
        //property 設定HP500並用private隱藏
        private int HP = 500;
        //method   可以得到我的HP多少
        public int GetHP()
        {
            return HP;
        }
        //受傷的method
        public void Injured(int injured)
        {
            HP -= injured;
        }
        
    }
Derived Class(衍生類別)
class Villager : Creature //繼承Creature
    {
        public string Talk()
        {
            return "今天天氣不錯";
        }
    }
Derived Class(衍生類別)
class Monster : Creature  //繼承Creature
    {
        //攻擊的method,因為繼成了Creatur所以參數可以使用基底類別系統自己會判斷是哪一個衍生類別
        public void Attack(Creature c)
        {
            c.Injured(10);
        }
    }
主程式:
private void Button1_Click(object sender, EventArgs e)
        {
            Villager v1 = new Villager();
            Monster m1 = new Monster();
            Monster m2 = new Monster();
            //m2開始攻擊v1、m1
            m2.Attack(v1);
            m2.Attack(m1);
            //顯示v1、m1的HP
            MessageBox.Show("" + v1.GetHP());
            MessageBox.Show("" + m1.GetHP());
        }
結語:花一點時間來理解繼承的部分,如有錯誤請跟小弟通知!謝謝